<admintpl file="header" />
<style type="text/css">
.pic-list li {
	margin-bottom: 5px;
}
</style>

</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:U('AdminCard/add',array('id'=>empty($item['id'])?'':$item['id']))}" target="_self">卡片充值</a></li>
		</ul>
		<form action="{:U('AdminCard/recharge_post')}" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data" onsubmit="return checkform();">
            <input type="hidden" name="_str" value="{:md5(time())}">
			<div class="row-fluid">
				<div class="span9">
					<table class="table table-bordered">

						<tr>
							<th>账户余额</th>
							<td>
                                <input type="text" name="balance" id="balance" value="{$logistics.balance}" style="width: 400px" readonly>
                                <input type="hidden" name="logistics_id" id="logistics_id" value="{$logistics.id}" style="width: 400px" readonly>
                            </td>
						</tr>
                        <tr>
                            <th>充值卡号<span class="form-required">*</span></th>
                            <td><input type="text" name="card_number" id="card_number" class="require number" value="" style="width: 400px" placeholder="请输入绑定会员卡">
                                <input type="hidden" class="require" name="card_id"  id="card_id" value=""/>
                            </td>
                        </tr>
                        <tr>
                            <th>卡内余额</th>
                            <td><input type="text"  name="card_balance" id="card_balance" value="" style="width: 400px"readonly > </td>
                        </tr>
                        
                        <tr>
                            <th>会员姓名</th>
                            <td>
                                <input type="text" class="editable" name="vip_name" id="vip_name" value="" style="width: 400px" placeholder="请输入会员姓名" readonly>
                            </td>
                        </tr>
                        <tr>
                            <th>会员手机</th>
                            <td>
                                <input type="text" class="editable" name="vip_phone" id="vip_phone" value="" style="width: 400px" placeholder="请输入会员手机号" readonly>
                            </td>
                        </tr>
                        <tr>
                            <th>会员车牌</th>
                            <td>
                                <input type="text" class="editable" name="vip_plate_number" id="vip_plate_number" value="" style="width: 400px" placeholder="请输入充值汽车的车牌" readonly>
                            </td>
                        </tr>

                        <tr>
                            <th>赠送</th>
                            <td><input type="text"  name="admin_card_give_price" id="admin_card_give_price" value="" style="width: 400px"readonly > </td>
                        </tr>
                        <tr>
                            <th>卡费</th>
                            <td><input type="text"  name="admin_card_active_price" id="admin_card_active_price" value="" style="width: 400px"readonly > </td>
                        </tr>
                        <tr>
                            <th>充值金额<span class="form-required">*</span></th>
                            <td><input type="text" class="require number" name="recharge_price" id="recharge_price" value="" style="width: 400px"  placeholder="请输入充值金额"> </td>
                        </tr>
                        <!-- <tr>
                            <th>描述</th>
                            <td><input type="text" name="desc" id="desc" value="" style="width: 400px" placeholder="请输入描述"> </td>
                        </tr> -->

                    </table>
				</div>

			</div>
			<div class="form-actions">
                <input type="hidden" name="id" value="{$item.id}"/>
				<button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
				<a class="btn" href="{:U('AdminCard/index')}">返回</a>
			</div>
		</form>
	</div>
    <script type="text/javascript">
        $(document).ready(function () {
            // $("#select_card_number").quicksearch(".card_number_list li", {
            //     noResults: '.no_card_number_list'
            // });
            // $("#card_number,#select_card_number").click(function(){
            //     event.stopPropagation();
            //     $('.card_number_list').show();
            //     return false;
            // });
            // $("body").click(function(){
            //     $(".div_quicksearch").hide();
            // });
            // $("#select_card_number").keypress(function (e) { //这里给function一个事件参数命名为e，叫event也行，随意的，e就是IE窗口发生的事件。

            //     var key = e.which; //e.which是按键的值
            //     var is_select = false;
            //     if (key == 13) {
            //         setTimeout(function(){
            //             $(".card_number_list li").each(function(){
            //                var disp = $(this).css("display");
            //                if(disp != 'none'){
            //                    is_select = true;
            //                    $(this).click();
            //                     return false;
            //                }
            //             });
            //             // if(!is_select){
            //             //     alert("该卡号不存在!");
            //             // }
            //         },300);
            //         return false;
            //     }
            // });

            });
        function change_card_id(){
            var card_number = $("#card_number").val();
            var logistics_id = $("#logistics_id").val();

            $.ajax({url:"{:U('AdminCard/ajax_get_card')}",async:false,dataType:"json",data:"card_number="+card_number+"&logistics_id="+logistics_id,type:"post",success:function(t){
                    if(t.code == 1){
                        var temp = t.data;
                        $("#card_id").val(temp.id);
                        $("#card_balance").val(temp.balance);
                        $("#vip_phone").val(temp.vip_phone);
                        $("#vip_name").val(temp.vip_name);
                        $("#vip_plate_number").val(temp.vip_plate_number);
                        $("#car_code").val(temp.car_code);
                        $("#driver_name").val(temp.driver_name);
                        $("#admin_card_give_price").val(temp.admin_card_give_price);
                        $("#admin_card_active_price").val(temp.admin_card_active_price);
                    }else{
                        alert(t.data);
                    }
            }});
        }
        $('#card_number').change(function(){
            change_card_id();
        });

        // function quick_select(id,val,id2,val2){
        //     $("#"+id).val(val);
        //     $("#"+id2).val(val2);
        //     change_card_id();
        // }
        $('.editable').click(function(){
            $(this).removeAttr('readonly').select();
        });
        $('.editable').blur(function(){
            $(this).attr('readonly','readonly');
        });
    </script>

	<script type="text/javascript" src="__PUBLIC__/js/common.js?5"></script>
	</body>
</html>